﻿namespace Sustainalytics.Caching.L
{
    public abstract class L2Cache : IL2Cache
    {
        protected IAppCache Cache { get; private set; }

        public L2Cache(IAppCache cache)
        {
            if (cache == null)
            {
                throw new L2AppCacheNullException();
            }

            this.Cache = cache;
        }

        public void PushToCache(IAppCache otherCache)
        {
            if (otherCache == null)
            {
                throw new L2PushToAppCacheNullException();
            }

            this.Cache.PushToCache(otherCache);
        }

        public AppProxyCache CreateProxyCache(IAppCache proxyCache)
        {
            if (proxyCache == null)
            {
                throw new L2ProxyCacheIsNullException();
            }

            AppProxyCache proxyCacheInstance = new AppProxyCache(proxyCache, this.Cache);

            return proxyCacheInstance;
        }
    }
}
